﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Hosting;
using System.IO;
using System.Net.Http;

namespace FightSever.Core
{
    public class Controller : ApiController
    {
        public HttpResponseMessage Response { get; private set; }
        public Controller()
        {
            var response = Request.CreateResponse();
            this.Response = response;
        }
        protected HttpResponseMessage View(string name)
        {
            var full = HostingEnvironment.MapPath(name);
            var rsp = new HttpResponseMessage();
            if (!File.Exists(full))
            {
                this.Response.StatusCode = System.Net.HttpStatusCode.NotFound;
                return rsp;
            }
            var html = File.ReadAllText(full);
            rsp.Content = new StringContent(html);
            return rsp;
        }
    }
}
